﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.HVAC
{
	public partial class FireHydrantTypeForm : System.Windows.Forms.Form
	{
		public FireHydrantTypeForm()
		{
			this.InitializeComponent();
			new YJKProcessTools().ShowInTaskbarChange(this);
			base.Icon = Resource.YArchitechIcon;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			if (this.rbce.Checked)
			{
				this.fireHdType = "1";
			}
			else if (this.rbdi.Checked)
			{
				this.fireHdType = "2";
			}
			else if (this.rdoSide.Checked)
			{
				this.fireHdType = "3";
			}
			else if (this.rdoBack.Checked)
			{
				this.fireHdType = "4";
			}
			this.userSetting.WriteFireHDType(this.fireHdType);
			this.userSetting.WriteFireHDStyle(this.rdoPick.Checked.ToString());
			base.DialogResult = DialogResult.OK;
		}

		public bool BePickStyle()
		{
			return this.rdoPick.Checked;
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void FireHydrantTypeForm_Load(object sender, EventArgs e)
		{
			string fireHDTypeValue = this.userSetting.GetFireHDTypeValue();
			if (fireHDTypeValue == "1")
			{
				this.SetSideRadioStatue();
			}
			else if (fireHDTypeValue == "2")
			{
				this.SetDownRadioStatue();
			}
			else if (fireHDTypeValue == "3")
			{
				this.SetGroupSideRadioStatue();
			}
			else
			{
				this.SetBackRadioStatue();
			}
			if (this.userSetting.GetFireHDStyleValue())
			{
				this.rdoPick.Checked = true;
				this.rdoRectangle.Checked = false;
				return;
			}
			this.rdoPick.Checked = false;
			this.rdoRectangle.Checked = true;
		}

		private void SetSideRadioStatue()
		{
			this.rbce.Checked = true;
			this.rbdi.Checked = false;
			this.rdoBack.Checked = false;
			this.rdoSide.Checked = false;
		}

		private void SetDownRadioStatue()
		{
			this.rbce.Checked = false;
			this.rbdi.Checked = true;
			this.rdoBack.Checked = false;
			this.rdoSide.Checked = false;
		}

		private void SetGroupSideRadioStatue()
		{
			this.rbce.Checked = false;
			this.rbdi.Checked = false;
			this.rdoBack.Checked = false;
			this.rdoSide.Checked = true;
		}

		private void SetBackRadioStatue()
		{
			this.rbce.Checked = false;
			this.rbdi.Checked = false;
			this.rdoBack.Checked = true;
			this.rdoSide.Checked = false;
		}

		private void rdoBack_CheckedChanged(object sender, EventArgs e)
		{
			RadioButton radioButton = sender as RadioButton;
			if (radioButton == null || !radioButton.Checked)
			{
				return;
			}
			this.SetBackRadioStatue();
		}

		private void rdoSide_CheckedChanged(object sender, EventArgs e)
		{
			RadioButton radioButton = sender as RadioButton;
			if (radioButton == null || !radioButton.Checked)
			{
				return;
			}
			this.SetGroupSideRadioStatue();
		}

		private void rbdi_CheckedChanged(object sender, EventArgs e)
		{
			RadioButton radioButton = sender as RadioButton;
			if (radioButton == null || !radioButton.Checked)
			{
				return;
			}
			this.SetDownRadioStatue();
		}

		private void rbce_CheckedChanged(object sender, EventArgs e)
		{
			RadioButton radioButton = sender as RadioButton;
			if (radioButton == null || !radioButton.Checked)
			{
				return;
			}
			this.SetSideRadioStatue();
		}

		public string fireHdType = "1";

		private HVACUserSetting userSetting = new HVACUserSetting();
	}
}
